package com.ruoyi.merchant.service.impl;

import com.ruoyi.common.core.cg.pojo.Community;
import com.ruoyi.common.core.cg.pojo.Store;
import com.ruoyi.common.core.cg.pojo.TLeaderStore;
import com.ruoyi.merchant.mapper.CommunityMapper;
import com.ruoyi.merchant.mapper.StoreMapper;
import com.ruoyi.merchant.mapper.TLeaderStoreMapper;
import com.ruoyi.merchant.service.StoreService;
import com.ruoyi.merchant.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author ？？？
* @description 针对表【store】的数据库操作Service实现
* @createDate 2025-03-13 08:38:20
*/
@Service
public class StoreServiceImpl
    implements StoreService {

    @Autowired
    private StoreMapper storeMapper;
    @Autowired
    private TLeaderStoreMapper tLeaderStoreMapper;
    @Autowired
    private CommunityMapper communityMapper;
    @Override
    @Transactional
    public Result storeUpdate(String address,String name,Integer uid) {
        TLeaderStore leaderStore = tLeaderStoreMapper.selectById(uid);
        Integer storeId = leaderStore.getStoreId();

        System.err.println(storeId);

        Store store = new Store();
        store.setId(storeId);
        store.setName(name);
        store.setAddress(address);
        storeMapper.storeUpdate(store);

        System.err.println(uid);
        Community community = new Community();
        community.setLeaderId(uid);
        community.setAddress(address);
        communityMapper.communityUpdate(community);

        return Result.ok();
    }
}




